

package com.dog.basics.admin.controller.wishwash.admin;

import com.dog.basics.bean.dto.admin.wishwash.*;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.annotation.SysLog;
import com.dog.basics.common.util.R;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.vo.admin.wishwash.AdminDogHxDevVo;
import com.dog.basics.bean.vo.admin.wishwash.AdminDogHxDevInfoVo;

import com.dog.basics.bean.model.wishwash.DogHxDev;
import com.dog.basics.security.annotation.Inner;
import com.dog.basics.service.wishwash.DogHxDevService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;


/**
 * 设备信息
 *
 * @author cy code generator
 * @date 2021-07-09 17:40:27
 */
@RestController
@AllArgsConstructor
@RequestMapping("/admin/dev")
@Api(value = "设备信息管理", tags = "设备信息管理")
public class DogHxDevController {

    private final DogHxDevService dogHxDevService;

    /**
     * 分页查询
     *
     * @param page 分页对象
     * @param obj  设备信息
     * @return
     * @author cy code generator
     * @date 2021-07-09 17:40:27
     */
    @ApiOperation(value = "分页查询", notes = "admin_doghxdev_view")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('admin_doghxdev_view')")
    public R<IPage<AdminDogHxDevVo>> getDogHxDevPage(PageParam page, AdminDogHxDevFromDto obj) {
        return R.ok(dogHxDevService.getAdminPageList(page, obj));
    }


    /**
     * 设备详细信息统计
     *
     * @param id id
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:27
     */
    @ApiOperation(value = "设备详细信息统计", notes = "admin_doghxdev_info")
    @GetMapping("/{id}")
    @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "Long")
    @PreAuthorize("@pms.hasPermission('admin_doghxdev_info')")
    public R<AdminDogHxDevInfoVo> getById(@PathVariable("id") Long id) {
        return R.ok(dogHxDevService.getAdminObjXq(id));
    }

    /**
     * 新增设备信息
     *
     * @param obj 设备信息
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:27
     */
    @ApiOperation(value = "新增设备信息", notes = "admin_doghxdev_add")
    @SysLog("新增设备信息")
    @PostMapping
    @PreAuthorize("@pms.hasPermission('admin_doghxdev_add')")
    public R<Boolean> save(@Valid @RequestBody AdminDogHxDevAddDto obj) {
        return R.ok(dogHxDevService.saveAdminObj(obj));
    }

    /**
     * 修改设备信息
     *
     * @param obj 设备信息
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:27
     */
    @ApiOperation(value = "修改设备信息", notes = "admin_doghxdev_edit")
    @SysLog("修改设备信息")
    @PutMapping
    @PreAuthorize("@pms.hasPermission('admin_doghxdev_edit')")
    public R<Boolean> updateById(@Valid @RequestBody AdminDogHxDevEditDto obj) {
        return R.ok(dogHxDevService.editAdminObj(obj));
    }

    /**
     * @功能描述: 授权设备金额
     * @author He
     * @date 2021/9/23
     */
    @ApiOperation(value = "授权设备金额", notes = "admin_doghxdev_mone")
    @SysLog("授权金额")
    @PutMapping("/mone")
    @PreAuthorize("@pms.hasPermission('admin_doghxdev_mone')")
    public R<Boolean> updateMoneById(@Valid @RequestBody AdminDogHxDevModeDto obj) {
        return R.ok(dogHxDevService.updateMoneById(obj));
    }

    /**
     * 通过id删除设备信息
     *
     * @param id id
     * @return R
     * @author cy code generator
     * @date 2021-07-09 17:40:27
     */
    @ApiOperation(value = "通过id删除设备信息", notes = "admin_doghxdev_del")
    @SysLog("通过id删除设备信息")
    @DeleteMapping("/{id}")
    @PreAuthorize("@pms.hasPermission('admin_doghxdev_del')")
    @ApiImplicitParam(name = "id", value = "主键", required = true, dataType = "Long")
    public R<Boolean> removeById(@PathVariable Long id) {
        return R.ok(dogHxDevService.deleteObj(id));
    }

    /**
     * @功能描述: 绑定代理商
     * @author He
     * @date 2021/7/15
     */
    @ApiOperation(value = "绑定代理商", notes = "admin_doghxdev_agent")
    @PutMapping("/bd/agent")
    @PreAuthorize("@pms.hasPermission('admin_doghxdev_agent')")
    public R<Boolean> editBdAgentIds(@Valid @RequestBody AdminDogHxDevBdAgentDto dto) {
        return R.ok(dogHxDevService.editBdAgentIds(dto));
    }

    /**
     * @功能描述: 绑定场地
     * @author He
     * @date 2021/7/15
     */
    @ApiOperation(value = "绑定场地", notes = "admin_doghxdev_field")
    @PutMapping("/bd/field")
    @PreAuthorize("@pms.hasPermission('admin_doghxdev_field')")
    public R<Boolean> editBdfieldIds(@Valid @RequestBody AdminDogHxDevBdfieldDto dto) {
        return R.ok(dogHxDevService.editBdfieldIds(dto));
    }

    /**
     * @功能描述: 禁用启用
     * @author He
     * @date 2021/7/15
     */
    @ApiOperation(value = "禁用启用", notes = "禁用就是启用,启用就是禁用 [admin_doghxdev_forbidden]")
    @ApiImplicitParam(name = "devId", value = "设备标识", dataType = "Long")
    @PutMapping("/forbidden/{devId}")
    @PreAuthorize("@pms.hasPermission('admin_doghxdev_forbidden')")
    public R<Boolean> editForbidden(@PathVariable("devId") Long devId) {
        return R.ok(dogHxDevService.editAdminForbidden(devId));
    }

}
